import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
import { Form } from 'antd';
import React from 'react';
import { ClsPrefix } from '../consts';
import { FormAttrsContextProvider } from '../contexts/FormAttrsContext';
import { FormContextProvider } from '../contexts/FormContext';
import FormItem from '../FormItem';
import './index.css';
var _excluded = ['form', 'children', 'detail'];
/**
 * 基础表单容器，扩展详情展示功能
 * @param props FormProps
 * @returns
 */
var BaseForm = function BaseForm(props) {
  var form = props.form,
    children = props.children,
    detail = props.detail,
    rest = _objectWithoutProperties(props, _excluded);
  return /*#__PURE__*/ React.createElement(
    'div',
    {
      className: detail ? ''.concat(ClsPrefix, '-form-detail') : undefined,
    },
    /*#__PURE__*/ React.createElement(
      Form,
      _objectSpread(
        {
          form: form,
        },
        rest,
      ),
      /*#__PURE__*/ React.createElement(
        FormContextProvider,
        {
          value: form,
        },
        /*#__PURE__*/ React.createElement(
          FormAttrsContextProvider,
          {
            value: _objectSpread(
              {
                detail: detail,
              },
              rest,
            ),
          },
          children,
        ),
      ),
    ),
  );
};
BaseForm.List = Form.List;
BaseForm.Item = FormItem;
BaseForm.useForm = Form.useForm;
export default BaseForm;
